package com.kotodama.infrastructure.tenant.resolver.header;

import com.kotodama.infrastructure.tenant.resolver.TenantResolver;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.util.StringUtils;

/**
 * 从自定义请求头 X-Tenant-ID 解析租户
 */
public class HttpHeaderTenantResolver implements TenantResolver {
    public static final String HEADER = "X-Tenant-ID";

    @Override
    public String resolveTenantId(HttpServletRequest request) {
        String tenantId = request.getHeader(HEADER);
        return StringUtils.hasText(tenantId) ? tenantId : null;
    }
}
